# comun: small self hosted compiler
#
# This is a comun compiler that's supposed to be small, it only has the
# necessary features to turn source code into bytecode. This is useful for
# smaller devices, bootstrapping or Unix style piping. This compiler doesn't
# perform optimizations or give extensive warnings.
#
# usage: takes source code on input, outputs bytecode (or short error message)

~32 CMN_cMEM_SIZE: 2048 . ~0
~32 ~CMN_cMem:2048 ~0

~32 CMN_bBYTECODE_SIZE: 32768 . ~0
~16 ~CMN_bBytecode:32768 ~0

CMN_cInclude: .

~"cmn_compiler.cmn"

0 CMN_cInit

1 @ <- CMN_cFeedChar <? . # feed whole source to com

$CMN_cState CMN_cSTATE_DONE = ?
  CMN_bOutput
;
  "ERR A" -> -> -> -> $CMN_cState + -> 10 ->
.
